package com.hanqi.controller;


import com.alibaba.fastjson.JSONObject;
import com.hanqi.service.SysUserRoleService;
import com.hanqi.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zjk
 * @since 2019-04-27
 */
@Controller
@RequestMapping("/sysUserRole")
public class SysUserRoleController {

    @Autowired
    protected SysUserRoleService sysUserRoleService;

    @ResponseBody
    @RequestMapping("/updateRoleAuth")
    public JSONObject updateRoleAuth(String roleId, String userId, boolean opera) {
        if (opera) {
            sysUserRoleService.insertUserRoleAuth(userId, roleId);
        } else {
            sysUserRoleService.removeUserRoleAuth(userId, roleId);
        }
        return R.SUCCESS;
    }
}
